import onnx
from onnx import helper
from onnx import TensorProto
import numpy as np
 
weight = np.random.randn(9)
X = helper.make_tensor_value_info('X', TensorProto.FLOAT, [1,1,5,5])
W = helper.make_tensor('W', TensorProto.FLOAT, [1,1,3,3], weight)
Y = helper.make_tensor_value_info('Y', TensorProto.FLOAT, [1, 1,3,3])
 
node_def = helper.make_node(
    'Conv', # node name
    ['X', 'W'],
    ['Y'], # outputs
    # attributes
    strides=[1,1],
    )
 
graph_def = helper.make_graph(
    [node_def],
    'test_conv_mode',
    [X], # graph inputs
    [Y], # graph outputs
    initializer=[W],
)
 
mode_def = helper.make_model(graph_def, producer_name='onnx-example')
onnx.checker.check_model(mode_def)
onnx.save(mode_def, "./Conv.onnx")

